package momo.app.structure;

import momo.multitree.structure.Edge;

public class PeerLink extends Edge
{
	
	private Peer source, dest;
	private double cost;
	private double latency;
	
	public PeerLink(String id, Peer source, Peer dest, double cost, double latency)
	{
		super(id, source, dest, cost, cost, latency, latency);
		this.source = source;
		this.dest = dest;
		this.cost = cost;
		this.latency = latency;
	}
	
	public PeerLink(Peer source, Peer dest, double cost, double latency)
	{
		this(source.getId()+"-"+dest.getId(), source, dest, cost, latency);
	}

	public Peer getSource() {
		return source;
	}

	public Peer getDest() {
		return dest;
	}
	
	public void setCost(double cost)
	{
		this.cost = cost;
		super.setCost(source, cost);
		super.setCost(dest, cost);
	}

	public double getCost() {
		return cost;
	}
	
	public void setLatency(double latency)
	{
		this.latency = latency;
		super.setLatency(source, latency);
		super.setLatency(dest, latency);
	}

	public double getLatency() {
		return latency;
	}
	
	public String toString()
	{
		return source.getId() + ","
			+ dest.getId() + ","
			+ cost + ","
			+ latency;
	}
	
}//end of class PeerLink
